<template>
  <div class="app-container jklis">
    <div class="zdy-main customTab">
      <el-tabs
        type="border-card"
        v-model="actived"
        @tab-click="tabChange"
        v-loading="loading"
      >
        <el-form
          :model="queryParams"
          ref="queryForm"
          :inline="true"
          class="zdy-form search-form-new"
          label-width="68px"
          @keyup.enter.native="search"
        >
          <el-form-item label="商品编号" prop="id">
            <el-input
              v-model="queryParams.id"
              placeholder="请输入商品编号"
              clearable
              size="small"
            />
          </el-form-item>
          <el-form-item label="游戏名称" prop="gameId">
            <el-select
              v-model="queryParams.gameId"
              placeholder="请选择游戏"
              size="small"
              clearable
              @change="selectGameType"
            >
              <el-option
                v-for="dict in gameList"
                :key="dict.id"
                :label="dict.name"
                :value="dict.id"
              />
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="换绑状态" prop="monitoringState">
            <el-select
              v-model="queryParams.monitoringState"
              placeholder="请选择游戏"
              size="small"
            >
              <el-option
                v-for="dict in monitoringStateMap"
                :key="dict.type"
                :label="dict.name"
                :value="dict.type"
              />
            </el-select>
          </el-form-item> -->
          <el-form-item
            label="系统"
            prop="systemId"
            v-if="GameSelectedType === 0"
          >
            <el-select
              v-model="queryParams.systemId"
              placeholder="请选择"
              size="small"
              clearable
              @change="search"
              filterable
            >
              <el-option
                v-for="dict in sysList"
                :key="dict.id"
                :label="dict.fieldName"
                :value="dict.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            label="运营商"
            prop="carrierId"
            v-if="GameSelectedType === 0"
          >
            <el-select
              v-model="queryParams.carrierId"
              placeholder="请选择"
              size="small"
              clearable
              @change="getAreaList"
              filterable
            >
              <el-option
                v-for="dict in carrierList"
                :key="dict.id"
                :label="dict.fieldName"
                :value="dict.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="大区" prop="groupId">
            <el-select
              v-model="queryParams.groupId"
              placeholder="请选择"
              size="small"
              clearable
              @change="getServiceList"
              filterable
            >
              <el-option
                v-for="dict in areaList"
                :key="dict.id"
                :label="dict.fieldName"
                :value="dict.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="服务器" prop="serverId">
            <el-select
              v-model="queryParams.serverId"
              placeholder="请选择"
              size="small"
              clearable
              @change="search"
              filterable
            >
              <el-option
                v-for="dict in serverList"
                :key="dict.id"
                :label="dict.fieldName"
                :value="dict.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="价格区间" prop="price" class="mm-b-8">
            <div class="two-input-content">
              <el-input
                size="small"
                v-model="queryParams.priceStart"
                class="two-input-item"
                style="width: 100px !important"
              ></el-input>
              <span>-</span>
              <el-input
                size="small"
                v-model="queryParams.priceEnd"
                class="two-input-item"
                style="width: 100px !important"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item label="销售时间" prop="price" class="mm-b-8">
            <div class="two-input-content">
              <el-date-picker
                @change="selectSaleTime"
                v-model="saleTimeArr"
                size="small"
                format="yyyy-MM-dd"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              ></el-date-picker>
            </div>
          </el-form-item>
          <el-form-item
            v-hasPermi="['supply:list:search']"
            label="供货商"
            prop="createIds"
          >
            <el-select
              multiple
              v-model="queryParams.createIds"
              placeholder="请选择"
              size="small"
              clearable
              filterable
            >
              <el-option
                v-for="dict in supplyList"
                :key="dict.userId"
                :label="dict.nickName"
                :value="dict.userId"
              />
            </el-select>
          </el-form-item>

          <!-- <el-form-item label="商品描述" prop="des">
            <el-input v-model="queryParams.des" placeholder="请输入商品描述" clearable size="small" />
          </el-form-item> -->
          <el-form-item label="关键字" prop="keyWord">
            <el-input
              v-model="queryParams.keyWord"
              placeholder="多个关键字用空格隔开"
              clearable
              size="small"
            />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="search"
              class="zdy-btn"
              >搜索</el-button
            >
          </el-form-item>
          <el-form-item>
            <el-button
              icon="el-icon-refresh"
              type="primary"
              size="mini"
              plain
              @click="resetQuery"
              class="zdy-btn zdy-btn-refresh"
              >重置</el-button
            >
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="openMoreSearch"
              class="zdy-btn"
              >更多搜索</el-button
            >
          </el-form-item>
          <el-form-item v-if="pageType == 'check'">
            <el-button
              icon="el-icon-plus"
              type="primary"
              size="mini"
              @click="checkAccountFn(false)"
              class="zdy-btn zdy-btn-refresh"
              >批量审核</el-button
            >
          </el-form-item>
          <el-form-item
            v-if="
              pageType != 'check' &&
              pageType != 'pool' &&
              pageType != 'salePort'
            "
          >
            <el-button
              icon="el-icon-plus"
              type="primary"
              size="mini"
              @click="addACount"
              class="zdy-btn zdy-btn-refresh"
              >发布</el-button
            >
          </el-form-item>
          <el-form-item v-if="pageType == 'check'">
            <el-button type="danger" size="mini" @click="handleDelete()"
              >删除</el-button
            >
          </el-form-item>
          <!-- <el-form-item v-if="pageType != 'check'&&pageType!='pool'">
            <el-button icon="el-icon-document-copy" type="primary" size="mini" @click="addACountMore"
              class="zdy-btn zdy-btn-refresh">批量发布</el-button>
          </el-form-item> -->
          <el-form-item v-if="pageType == 'salePort' && actived != 7">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              @click="copyBatch"
              >批量复制</el-button
            >
          </el-form-item>
          <el-form-item v-if="pageType == 'admin' && actived != 7">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              @click="piliangXiajia"
              >批量下架</el-button
            >
          </el-form-item>

          <el-form-item v-if="actived != 7">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              v-if="pageType == 'admin'"
              @click="deleteAll"
              >全部下架</el-button
            >
          </el-form-item>
          <el-form-item v-hasPermi="['bacth:push']" v-if="actived != 7">
            <el-dropdown @command="pushBatch" v-if="pageType == 'admin'">
              <el-button type="primary" size="mini">
                批量推送
                <i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                  v-for="item in pushApiList"
                  :command="item.id"
                  :key="item.id"
                  >{{ item.name }}</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </el-form-item>
          <el-form-item>
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              :loading="exportLoading"
              @click="handleExport"
              >导出</el-button
            >
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              :loading="exportLoading"
              @click="handleExportss"
              >导出三方</el-button
            >
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              :loading="exportLoading"
              @click="handleExportssJYM"
              >导出交易猫</el-button
            >
          </el-form-item>
        </el-form>
        <el-tab-pane
          :label="tab.name"
          :name="tab.value"
          v-for="tab in statusList"
          :key="tab.value"
        >
          <div
            v-if="!tableData.records || tableData.records.length == 0"
            style="height: calc(100vh - 360px)"
          ></div>
          <el-table
            :data="tableData.records"
            @cell-dblclick="handleUpdate"
            @sort-change="sortFun"
            height="calc(100vh - 360px)"
            style="width: 100%"
            v-if="tableData.records && tableData.records.length"
            @selection-change="handleSelection"
          >
            <el-table-column type="selection" width="55"> </el-table-column>
            <el-table-column
              label="商品编号"
              sortable="custom"
              width="100"
              label-position="left"
              sort-by
            >
              <template slot-scope="scope">
                <span
                  v-show="actived == 3 && scope.row.selltype"
                  class="sign"
                  :class="{ ping: scope.row.selltype == 1 }"
                  >{{ scope.row.selltype == 1 ? "平" : "自" }}</span
                >
                <!-- <span v-if="scope.row.lable == 0" style="color: #ff6d6d">{{scope.row.id}}</span> -->
                <span>{{ scope.row.id }}</span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="actived == 7"
              label="删除人"
              width="100"
              prop="delUserName"
            />
            <el-table-column
              v-if="actived == 4"
              label="下架原因"
              width="160"
              prop="downDes"
            />
            <el-table-column
              v-if="actived == 2"
              label="提号人"
              width="100"
              prop="submituserName"
            />
            <el-table-column
              v-if="actived == 2"
              label="提号时间"
              width="160"
              prop="submittime"
            />
            <el-table-column
              v-if="actived == 2"
              label="提号备注"
              width="160"
              prop="salenote"
            >
              <template slot-scope="scope">
                <span
                  @click="editTihaoBeizhu(scope.row)"
                  style="cursor: pointer; color: cornflowerblue"
                  >{{ scope.row.salenote }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              v-if="actived == 5"
              label="问题时间"
              width="160"
              prop="problemtime"
            />
            <el-table-column
              v-if="actived == 5"
              label="问题类型"
              width="120"
              prop="problemTypeName"
            >
              <template slot-scope="scope">
                <span
                  @click="editProblemDes(scope.row)"
                  style="cursor: pointer; color: cornflowerblue"
                  >{{ scope.row.problemTypeName }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              v-if="actived == 5"
              label="转问题人"
              width="100"
              prop="problemUserName"
            >
            </el-table-column>
            <el-table-column
              v-if="actived == 5 || (actived == 0 && pageType == 'check')"
              label="问题描述"
              width="160"
              prop="problemDes"
            >
              <template slot-scope="scope">
                <span
                  @click="editProblemDes(scope.row)"
                  style="cursor: pointer; color: cornflowerblue"
                  >{{ scope.row.problemDes }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              v-if="actived == 6"
              label="转找回人"
              width="100"
              prop="retrieveUserName"
            />
            <el-table-column
              v-if="actived == 6"
              label="找回原因"
              width="160"
              prop="retrieveDes"
            />
            <el-table-column
              v-if="actived == 0"
              label="状态"
              width="120"
              prop="saleState"
            >
              <template slot-scope="scope">
                <el-tag
                  :type="
                    statusMap[scope.row.saleState]
                      ? statusMap[scope.row.saleState].type
                      : ''
                  "
                  >{{
                    statusMap[scope.row.saleState]
                      ? statusMap[scope.row.saleState].name
                      : ""
                  }}</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column label="游戏名称" width="100" prop="gameName" />
            <!-- <el-table-column label="商品标题" width="200" prop="title">
              <template slot-scope="scope">
                <el-tooltip class="item" effect="dark" :content="scope.row.title" placement="top-start">
                  <div class="zdy-des">{{ scope.row.title }}</div>
                </el-tooltip>
              </template>
            </el-table-column> -->
            <el-table-column label="区服" width="130" prop="systemName">
              <template slot-scope="scope">
                <span>{{
                  scope.row.systemName ? scope.row.systemName + "/" : ""
                }}</span>
                <span>{{
                  scope.row.carrierName ? scope.row.carrierName + "/" : ""
                }}</span>
                <span>{{
                  scope.row.groupName ? scope.row.groupName + "/" : ""
                }}</span>
                <span>{{ scope.row.serverName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="商品描述" min-width="500" prop="des">
              <template slot-scope="scope">
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="scope.row.des"
                  placement="top-start"
                >
                  <div class="zdy-des">{{ scope.row.des }}</div>
                </el-tooltip>
              </template>
            </el-table-column>
            <!-- v-if="pageType != 'salePort'||(pageType == 'salePort'&&(actived == 3||actived == 4||actived == 5))" -->
            <el-table-column
              v-if="
                (!irreAttr && pageType != 'pool' && pageType != 'salePort') ||
                (pageType == 'salePort' &&
                  (actived == 3 || actived == 4 || actived == 5))
              "
              label="账号"
              width="100"
              prop="accountNumber"
            />
            <el-table-column
              v-if="
                (!irreAttr && pageType != 'pool' && pageType != 'salePort') ||
                (pageType == 'salePort' &&
                  (actived == 3 || actived == 4 || actived == 5))
              "
              label="密码"
              width="100"
              prop="accountPassword"
            />
            <el-table-column
              v-if="
                (!irreAttr && pageType != 'pool' && pageType != 'salePort') ||
                (pageType == 'salePort' &&
                  (actived == 3 || actived == 4 || actived == 5))
              "
              label="手机号"
              width="110"
              prop="securityPhone"
            />
            <el-table-column
              v-if="pageType == 'salePort' && actived == 3"
              label="销售渠道"
              width="110"
              prop="saleChannel"
            />
            <!-- <el-table-column label="自编号" width="100" prop="thirdId" /> -->
            <el-table-column
              label="售价"
              width="100"
              prop="newPrice"
              v-if="
                pageType == 'salePort' ||
                pageType == 'admin' ||
                pageType == 'check'
              "
            >
              <template slot-scope="scope">
                <div
                  v-show="scope.$index !== showInputIndex"
                  @click="priceClick(scope.$index, scope.row)"
                >
                  {{ scope.row.newPrice }}
                </div>
                <el-input
                  :ref="'priceInput' + scope.row.id"
                  v-show="scope.$index === showInputIndex"
                  v-model="scope.row.newPrice"
                  @blur="showInputIndex = ''"
                  @change="priceEdit(scope.row)"
                ></el-input>
                <!-- <div v-if="pageType != 'check'">
                  <el-popover @show="getMore(scope.row)" placement="left" title="更多" width="250" trigger="click">
                    <el-table :data="morePrice">
                      <el-table-column width="100" property="saleName" label="销售名称"></el-table-column>
                      <el-table-column width="100" property="price" label="价格"></el-table-column>
                    </el-table>
                    <el-button slot="reference" size="mini">更多</el-button>
                  </el-popover>
                </div> -->
              </template>
            </el-table-column>
            <el-table-column
              label="回收价"
              width="100"
              prop="costPrice"
              sortable="custom"
              sort-by
            />
            <el-table-column
              label="回收人"
              width="100"
              prop="recyclerName"
              v-if="pageType == 'admin'"
            />
            <!-- recyclerName -->

            <el-table-column
              label="供货客服"
              width="100"
              prop="supplyName"
              v-if="pageType == 'admin' || pageType == 'salePort'"
            >
              <template slot-scope="scope">
                <div>
                  <el-popover
                    @show="getSupPhone(scope.row)"
                    placement="right"
                    :title="scope.row.supplyName"
                    width="250"
                    trigger="click"
                  >
                    <div>{{ supPhoneNum }}</div>
                    <el-button type="text" slot="reference" size="mini">{{
                      scope.row.supplyName
                    }}</el-button>
                  </el-popover>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              label="三方ID"
              width="136"
              prop="outid"
              v-if="
                (pageType == 'admin' && actived == 1) ||
                (pageType == 'salePort' && actived == 1)
              "
            >
              <template #default="{ row }">
                <el-button
                  size="mini"
                  type="primary"
                  @click="dianjithreeId(row)"
                  >点击获取</el-button
                >
              </template>
            </el-table-column>
            <!-- <el-table-column label="销售客服" width="100" prop="salaName"
              v-if="pageType == 'admin' || pageType == 'salePort'" /> -->
            <el-table-column
              sortable="custom"
              sort-by
              label="供货价"
              width="100"
              prop="price"
            />
            <el-table-column
              label="重要信息备注"
              width="150"
              prop="importantRemark"
              v-if="
                pageType != 'salePort' ||
                (pageType == 'salePort' &&
                  (actived == 3 || actived == 4 || actived == 5))
              "
            >
              <template slot-scope="scope">
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="scope.row.importantRemark"
                  placement="top-start"
                >
                  <div class="zdy-des">{{ scope.row.importantRemark }}</div>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column
              sortable="custom"
              sort-by
              v-if="!irreAttr"
              label="上架时间"
              width="160"
              prop="createTime"
            />
            <el-table-column
              sortable="custom"
              sort-by
              v-if="actived == 3"
              label="销售时间"
              width="160"
              prop="saletime"
            />
            <el-table-column
              label="换绑状态"
              v-if="actived == 3"
              align="center"
              prop="supllypay"
              fixed="right"
              width="100"
            >
              <template slot-scope="scope">
                <div
                  v-if="scope.row.isBindStatus == 0"
                  style="
                    width: 62px;
                    height: 26px;
                    line-height: 26px;
                    text-align: center;
                    background-color: #e8f4ff;
                    border-radius: 5px;
                    margin: 0 auto;
                    border: 1px solid #d1e9ff;
                    color: #7cbfff;
                    cursor: pointer;
                  "
                >
                  未换绑
                </div>
                <div
                  v-else
                  style="
                    width: 62px;
                    height: 26px;
                    line-height: 26px;
                    text-align: center;
                    background-color: #fef0f0;
                    border-radius: 5px;
                    margin: 0 auto;
                    border: 1px solid #f593a8;
                    color: #f593a8;
                    cursor: pointer;
                  "
                >
                  已换绑
                </div>
              </template>
            </el-table-column>
            <el-table-column
              fixed="right"
              label="操作"
              :width="'160'"
              v-if="actived != 7"
            >
              <template slot-scope="scope">
                <el-button
                  type="text"
                  style="color: red"
                  size="mini"
                  v-if="pageType == 'myAccount' && actived == 1"
                  @click="openOnSelf(scope.row)"
                  >转自售</el-button
                >
                <!-- <el-button type="text" style="color:red" size="mini" v-if="pageType=='check'"
                  @click="handleDelete(scope.row)">删除</el-button> -->
                <!-- <el-button type="text" style="color:red" size="mini" v-if="actived == 1 && pageType != 'pool'"
                  @click="downSale(scope.row.id)">下架</el-button> -->
                <el-button
                  type="text"
                  size="mini"
                  v-if="actived == 4 || actived == 5 || actived == 2"
                  @click="upSale(scope.row.id)"
                  >上架</el-button
                >
                <el-button
                  type="text"
                  style="color: red"
                  size="mini"
                  v-if="
                    actived == 1 ||
                    actived == 4 ||
                    actived == 3 ||
                    (pageType == 'salePort' && actived == 2)
                  "
                  @click="transQues(scope.row)"
                  >转为问题号</el-button
                >
      
                <el-button
                  v-if=" actived == 3"
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="bindAccountDetail(scope.row)"
                  v-hasPermi="['account:rec:remove']"
                  >查看换绑详情</el-button
                >
                <!-- <el-button type="text" style="color:red" size="mini"
                  v-if="(actived == 1 || actived == 4 || actived == 3) || (pageType == 'salePort' && actived == 2)"
                  @click="resetUnbind(scope.row)">重置绑定状态</el-button> -->
                <el-button
                  type="text"
                  style="color: red"
                  size="mini"
                  v-if="
                    pageType == 'salePort' &&
                    actived == 3 &&
                    scope.row.gameXINType == '网易' &&
                    scope.row.useStatus == '0'
                  "
                  @click="yikongxian(scope.row)"
                  >转已空闲</el-button
                >
                <el-button
                  type="text"
                  style="color: red"
                  size="mini"
                  v-if="pageType == 'admin' && actived == 1"
                  @click="toTop(scope.row)"
                  >刷新</el-button
                >
                <el-button
                  type="text"
                  style="color: red"
                  size="mini"
                  v-if="
                    actived == 5 &&
                    (pageType == 'salePort' || pageType == 'admin')
                  "
                  @click="transZhaohui(scope.row)"
                  >转为找回</el-button
                >
                <el-button
                  type="text"
                  size="mini"
                  v-if="
                    actived == 5 &&
                    (pageType == 'salePort' || pageType == 'admin')
                  "
                  @click="transYishou(scope.row)"
                  >转为已售</el-button
                >
                <el-button
                  type="text"
                  size="mini"
                  v-if="actived == 6"
                  @click="transZhaohuiEdit(scope.row)"
                  >找回原因</el-button
                >
                <el-button
                  type="text"
                  size="mini"
                  v-if="actived == 2 && pageType == 'salePort'"
                  @click="commitOrder(scope.row)"
                  >下单</el-button
                >
                <el-button
                  type="text"
                  size="mini"
                  v-if="actived == 1 && pageType == 'salePort'"
                  @click="addOrder(scope.row)"
                  >提号</el-button
                >
                <el-button
                  type="text"
                  size="mini"
                  v-if="actived == 1 && pageType == 'salePort'"
                  @click="yijiantuisong(scope.row)"
                  >一键推送</el-button
                >
                <el-button
                  ref="copyBtn1"
                  type="text"
                  size="mini"
                  v-if="
                    (actived == 0 && pageType == 'check') ||
                    (actived == 10 && pageType == 'check')
                  "
                  @click="checkAccountFn(scope.row)"
                  >审核</el-button
                >
                <el-button
                  ref="copyBtn1"
                  type="text"
                  size="mini"
                  v-if="actived == 1 || actived == 0 || actived == 10"
                  v-clipboard:copy="copyVlaue"
                  v-clipboard:error="onError"
                  v-clipboard:success="onCopy"
                  @click="keyCopy(scope.row)"
                  >复制</el-button
                >
                <el-button
                  ref="copyBtn1"
                  type="text"
                  size="mini"
                  v-if="actived == 2"
                  @click="keyCopy2(scope.row)"
                  >复制</el-button
                >
                <el-button
                  type="text"
                  size="mini"
                  @click="showLogs(scope.row.id)"
                  >日志</el-button
                >
                <el-button
                  type="text"
                  size="mini"
                  v-if="actived == 1"
                  @click="copyGood(scope.row.id)"
                  >克隆</el-button
                >
                <!-- <el-button type="text" size="mini" v-if="actived == 1 && pageType == 'admin'"
                  @click="clone(scope.row)">克隆</el-button> -->
                <!-- <el-button ref="copyBtn1" type="text" size="mini" v-if="actived == 1 && pageType == 'admin'"
                  @click="addCheck(scope.row)">加入验证</el-button> -->
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="pages-box">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryParams.pageNum"
        :page-sizes="[10, 20, 30, 40, 50, 60]"
        :page-size="queryParams.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="tableData.total"
      ></el-pagination>
    </div>
    <!-- 一下是弹出框 -->
    <h5Dialog ref="h5Dialog"></h5Dialog>
    <addDialog ref="addDialog"></addDialog>
    <onSelfDialog ref="onSelfDialog"></onSelfDialog>
    <importDialog ref="importDialog"></importDialog>
    <deleteDialog ref="deleteDialog"></deleteDialog>
    <pushDialog ref="pushDialog"></pushDialog>
    <orderCommit ref="orderCommit"></orderCommit>
    <moreSearch ref="moreSearch" @sureSearch="sureSearch"></moreSearch>
    <showLogs ref="showLogs"></showLogs>
    <zhaohuiDialog ref="zhaohuiDialog"></zhaohuiDialog>
    <zhuanWenTiDialog ref="zhuanWenTiDialog"></zhuanWenTiDialog>
    <tihaoDialog ref="tihaoDialog"></tihaoDialog>
    <editTihao ref="editTihao"></editTihao>
    <!-- tihaoDialog -->

    <el-dialog title="备注" :visible.sync="showSinNumVisible">
      <span>{{ sinNumShow }}</span>
    </el-dialog>
    <!-- 改变状态的确认备注 -->
    <el-dialog :title="showDialogTitle" :visible.sync="dialogFormVisible">
      <el-form :model="unsoldFrom">
        <el-form-item
          :label="showDialogTitle == '下架原因' ? '下架原因' : '备注'"
          label-width="auto"
        >
          <el-input v-model="unsoldFrom.note" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmSub">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 获取三方数据 -->
    <el-dialog title="三方平台" :visible.sync="dioVisiblethree">
      <el-dialog
        width="50%"
        title="新增"
        :visible.sync="innerVisible"
        append-to-body
        @close="closefnthreeinfo"
      >
        <el-form :model="threeObjAll" label-width="88px">
          <el-form-item label="游戏名称" prop="gameId">
            <el-select
              v-model="threeObjAll.config"
              placeholder="请选择游戏"
              size="small"
              clearable
              @change="selectthreeInfo"
            >
              <el-option
                v-for="dict in threeListAllInfo"
                :key="dict.id"
                :label="dict.name"
                :value="dict.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="三方id" prop="id">
            <el-input
              style="width: 266px"
              v-model="threeObjAll.outid"
              placeholder="请输入三方id"
              clearable
              size="small"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="closefnthreeinfo">取 消</el-button>
          <el-button type="primary" @click="confirmthreeInfo">确 定</el-button>
        </div>
      </el-dialog>
      <div>
        <div style="margin-bottom: 20px">
          <el-button type="primary" @click="addfnThreeId">新增</el-button>
        </div>
        <el-table :data="threeListAll" height="333" border style="width: 100%">
          <el-table-column
            prop="partnerName"
            label="三方名称"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="outid"
            label="三方ID"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column prop="" label="操作" align="center">
            <template #default="{ row }">
              <el-button type="text" style="color: red" @click="editoutId(row)"
                >编辑</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
    <!-- 一件推送 -->
    <el-dialog
      title="一键推送"
      :visible.sync="dioVisibleOneTS"
      @close="ONEcloseSubmit"
    >
      <el-dialog
        width="50%"
        title="二维码"
        :visible.sync="innerVisibleEWM"
        append-to-body
        @close="EWMSHIBIE"
      >
        <div style="margin-top: 8px; text-align: center">
          <div style="margin-bottom: 26px">
            请通过您要发布的QQ客户端扫描二维码，二维码60秒有效
          </div>
          <div id="qqq" ref="qrCodeDiv"></div>
        </div>
      </el-dialog>
      <el-form :model="YijiantsObj" v-loading="loadingFB" label-width="88px">
        <el-form-item label="推送渠道" prop="gameId">
          <el-select
            v-model="YijiantsObj.config"
            v-if="erweimaObj.status != 2"
            placeholder="请选择推送渠道"
            size="small"
            clearable
            filterable
            @change="selectONEInfo"
          >
            <el-option
              v-for="dict in pushAllListNew"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="ONEcloseSubmit" v-if="erweimaObj.status != 2"
          >取 消</el-button
        >
        <el-button
          type="primary"
          @click="ONEsaleSubmit"
          v-if="erweimaObj.status != 2"
          >确 定</el-button
        >
      </div>
    </el-dialog>

    <!-- 换绑 -->
    <el-dialog
      title="换绑"
      :visible.sync="dialogVisibleChangeBinding"
      width="50%"
      @close="onclose"
    >
      <el-form ref="form" :model="formData" label-width="100px">
        <el-form-item label="换绑类型">
          <el-select
            :disabled="Viewflag"
            v-model="formData.bindStatus"
            placeholder="请选择换绑类型"
          >
            <el-option
              v-for="(item, index) in buyerList"
              :key="index"
              :label="item.dictLabel"
              :value="item.dictLabel"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="换绑手机号">
          <el-input
            :disabled="Viewflag"
            style="width: 300px"
            v-model="formData.buyerPhone"
            placeholder="请输入买家换绑手机号"
          ></el-input>
        </el-form-item>
        <el-form-item label="换绑截图" prop>
          <div class="flex">
            <el-upload
              :disabled="Viewflag"
              :action="uploadImgUrl"
              :file-list="buyerImgList"
              :show-file-list="true"
              list-type="picture-card"
              multiple
              :on-success="handleAvatarSuccess"
              :on-remove="handleAvatarRemove"
              :on-preview="handlePictureCardPreview"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </div>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="onclose">取 消</el-button>
        <el-button v-if="!Viewflag" type="primary" @click="bindStatusSure"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  getSupplyList,
  getMorePrice,
  getSupPhoneNumber,
  auditInfo,
  getPushList,
} from "@/api/info/info";
import h5Dialog from "../saleList/h5Dialog.vue";
import moment from "moment";
import addDialog from "./add.vue";
import showLogs from "./showLogs";
import onSelfDialog from "./onSelfDialog.vue";
import importDialog from "./importExel.vue";
import deleteDialog from "./allDelete.vue";
import orderCommit from "./orderCommit.vue";
import pushDialog from "./push.vue";
import moreSearch from "./moreSearch.vue";
import goodsListApi from "../../../api/gameConfig/goodsList";
import gameDictionaryApi from "../../../api/gameConfig/gameDictionary";
import gameListApi from "@/api/gameConfig/gameList";
import { getDicts } from "@/api/system/dict/data";
import checkPhoneApi from "../../../api/gameConfig/checkPhone";
import zhaohuiDialog from "./zhaohuiDialog.vue";
import zhuanWenTiDialog from "./zhuanWenTiDialog.vue";
import editTihao from "./editTihaoBeizhu.vue";
import tihaoDialog from "./tihaoDialog.vue";
import { formatDate } from "@/utils/index";
import phoneApi from "../../../api/phoneManage";
import QRCode from "qrcodejs2";
import supplyConfigApi from "@/api/system/supplyConfig";

export default {
  name: "goodsList",
  components: {
    addDialog,
    importDialog,
    onSelfDialog,
    moreSearch,
    deleteDialog,
    pushDialog,
    orderCommit,
    h5Dialog,
    showLogs,
    zhaohuiDialog,
    zhuanWenTiDialog,
    tihaoDialog,
    editTihao,
  },
  data() {
    return {
      Timer: null,
      oneStatusMsg: "",
      oneStatusObj: {},
      erweimaObj: {},
      dioVisiblethree: false,
      dioVisibleOneTS: false,
      threeListAll: [],
      threeObj: {},
      saleTimeArr: [],
      showInputIndex: "",
      supPhoneNum: "",
      gameList: [], //游戏列表
      tableData: {
        records: [],
        total: 0,
      },
      pageType: "",
      monitoringStateMap: {
        0: {
          name: "正常",
          type: "1",
        },
        1: {
          name: "已掉绑",
          type: "2",
        },
        2: {
          name: "未检测",
          type: "3",
        },
      },
      statusMap: {
        0: {
          name: "待审核",
          type: "warning",
        },
        1: {
          name: "未出售",
          type: "success",
        },
        2: {
          name: "交易中",
          type: "warning",
        },
        3: {
          name: "已出售",
          type: "",
        },
        4: {
          name: "已下架",
          type: "danger",
        },
        5: {
          name: "问题账号",
          type: "danger",
        },
        6: {
          name: "找回账号",
          type: "danger",
        },
        10: {
          name: "待入库",
          type: "warning",
        },
      },
      statusList: [
        {
          name: "全部",
          value: "",
        },
        {
          name: "未出售",
          value: "1",
        },
        {
          name: "交易中",
          value: "2",
        },
        {
          name: "已出售",
          value: "3",
        },
        // {
        //   name: "已下架",
        //   value: "4"
        // },
        {
          name: "问题账号",
          value: "5",
        },
        {
          name: "找回账号",
          value: "6",
        },
        {
          name: "已删除",
          value: "7",
        },
      ],
      actived: null,
      GameSelectedType: "", //筛选的游戏的类型
      sysList: [],
      carrierList: [], //运营商列表
      areaList: [], //大区列表
      serverList: [], //服务器列表
      selects: [], //表格的选中项
      ids: [], //表格选中的ids
      pushApiList: [],
      morePrice: [], //更多价格

      supplyList: [],
      levelArr: [],
      irreAttr: false, //隐藏无关字段
      showSinNumVisible: false, //查看备注
      sinNumShow: "",
      unsoldFrom: {
        note: null,
      },
      YijiantsObj: {
        config: null,
      },
      pushAllListNew: [],
      showDialogTitle: "",
      dialogFormVisible: false,
      tempData: null,
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        saleState: "",
        createIds: [],
        //        sort: "descending",
        //        sortColumn: "createTime",
        dataType: "all",
      },
      regionalArr: [], //区服列表
      copyVlaue: "",
      customAttr: null,
      retailDomainList: [],
      threeListAllInfo: [],
      exportLoading: false,
      innerVisible: null,
      threeObjAll: {
        accountId: null,
        config: null,
        saleCode: null,
        type: "add",
        outid: null,
      },
      ONEObj: null,
      ONEsaleObj: null,
      innerVisibleEWM: false,
      loadingFB: false,
      dialogVisibleChangeBinding: false,
      formData: {
        bindStatus: null,
        buyerPhone: null,
        buyerImg: null,
      },
      buyerImgList: [],
      buyerList: [],
      uploadImgUrl: "",
      Viewflag: false,
    };
  },
  mounted() {},
  created() {
    this.uploadImgUrl = process.env.VUE_APP_BASE_API + "/upload/image";

    if (this.$route.query.type) {
      this.pageType = this.$route.query.type;
      if (this.pageType == "check") {
        this.statusList = [
          {
            name: "待入库",
            value: "10",
          },
          {
            name: "待审核",
            value: "0",
          },
          {
            name: "已删除",
            value: "7",
          },
        ];
        this.actived = "10";
        this.queryParams.saleState = this.actived || 0;
        console.log("this.queryParams.saleState", this.queryParams.saleState);
      } else if (this.pageType == "pool") {
        this.statusList = [
          {
            name: "未出售",
            value: "1",
          },
        ];
        this.actived = "1";
        this.queryParams.saleState = this.actived;
      }
      if (
        this.pageType == "pool" ||
        this.pageType == "admin" ||
        this.pageType == "salePort" ||
        this.pageType == "check"
      ) {
        this.queryParams.dataType = "all";
      } else {
        this.queryParams.dataType = "one";
      }
    }
    this.getList();
    this.getGameList();
    this.getPushList();
    this.getPushListNew();
    this.getDomain();
    this.getUserList();
    this.getbuyerInfo();
  },
  methods: {
    bindAccount(item) {
      this.formData.id = item.id;
      this.dialogVisibleChangeBinding = true;
    },
    onclose() {
      this.Viewflag = false;
      this.formData = {
        bindStatus: null,
        buyerPhone: null,
        buyerImg: null,
      };
      this.dialogVisibleChangeBinding = false;
      this.buyerImgList = [];
    },
    async bindStatusSure() {
      const res = await supplyConfigApi.getbindiungInfo(this.formData);
      console.log(res);
      this.$message.success("操作成功!");
      this.getList();
      this.onclose();
    },
    async getbuyerInfo() {
      const res = await getDicts("bindOrderRec");
      this.buyerList = res.data;
    },
    bindAccountDetail(item) {
      console.log("item", item);
      this.Viewflag = true;
      this.dialogVisibleChangeBinding = true;
      this.formData.bindStatus = item.bindStatus;
      this.formData.buyerPhone = item.buyerPhone;
      this.buyerImgList = JSON.parse(item.buyerImg);
    },
    // 图片预览
    handleAvatarRemove(e, file, fileList) {
      console.log("e,file", e, file);
      file.forEach((item) => {
        this.buyerImgList.push({ url: item.response.data.filePath });
      });
      // this.buyerImgList = file;
      this.formData.buyerImg = JSON.stringify(this.buyerImgList);
    },
    handleAvatarSuccess(e, file, fileList) {
      console.log("e,file", e, file, fileList);
      fileList.forEach((item) => {
        this.buyerImgList.push({ url: item.response.data.filePath });
      });
      // this.buyerImgList = fileList;
      // console.log("e,this.buyerImgList", this.buyerImgList);
      this.formData.buyerImg = JSON.stringify(this.buyerImgList);
    },

    handlePictureCardPreview(file) {
      this.$viewerApi({
        images: [file.url],
      });
    },
    // 克隆商品
    copyGood(goodsId) {
      goodsListApi.copyGoods(goodsId).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("操作成功");
          this.getList();
        }
      });
    },
    //一键推送
    yijiantuisong(item) {
      this.ONEObj = item;
      this.dioVisibleOneTS = true;
    },
    selectONEInfo(e) {
      let obj = this.pushAllListNew.filter((item) => item.id == e);
      this.ONEsaleObj = obj[0];
    },
    // 获取推送渠道
    getPushListNew() {
      goodsListApi.pushAllList().then((res) => {
        this.pushAllListNew = res.rows;
      });
    },
    ONEcloseSubmit() {
      window.clearInterval(this.Timer);
      this.ONEObj = null;
      this.YijiantsObj = {
        config: null,
      };
      this.dioVisibleOneTS = false;
      this.erweimaObj = null;
      this.getList();
    },
    async ONEsaleSubmit() {
      const res = await goodsListApi.onejiantuisong(
        this.ONEObj.id,
        this.ONEsaleObj.id
      );
      console.log("res", res);
      this.oneStatusObj = res.data;
      this.oneStatusMsg = res.data.result.status;
      if (this.oneStatusMsg == 2) {
        this.Timer = setInterval(() => {
          this.erweimaObj = {};
          this.geterweima();
        }, 3000);
      } else {
        return this.$message.error(res.data.result.resultMsg);
      }
    },
    async geterweima() {
      const res = await goodsListApi.geterweimaTS(
        this.ONEObj.id,
        this.oneStatusObj.result.taskId,
        this.ONEsaleObj.id
      );
      console.log("res", res);
      this.erweimaObj = res.data.result;
      if (this.erweimaObj.status == 1) {
        this.innerVisibleEWM = true;
        this.$refs.qrCodeDiv.innerHTML = "";
        this.bindCode();
      } else if (this.erweimaObj.status == 2) {
        window.clearInterval(this.Timer);
        this.innerVisibleEWM = false;
        this.fabuButton();
        // return this.$message.error(this.erweimaObj.tipContent)
      }
    },
    // 发布
    async fabuButton() {
      this.loadingFB = true;
      let body = JSON.stringify(this.erweimaObj);
      console.log("body", body);
      let obj = {};
      obj.body = body;
      obj.goodId = this.ONEObj.id;
      obj.saleId = this.ONEsaleObj.id;
      const res = await goodsListApi.fabuerweimaTS(obj);
      console.log(res);
      if (res.data.result.success) {
        this.loadingFB = false;
        this.dioVisibleOneTS = false;
        this.$message.success("发布成功");
      } else {
        this.loadingFB = false;
        this.dioVisibleOneTS = false;
        this.$message.error("发布失败");
      }
    },
    bindCode() {
      this.$nextTick(function () {
        new QRCode(this.$refs.qrCodeDiv, {
          text: this.erweimaObj.qrCodeUrl, //二维码路径
          width: 300,
          height: 300,
          colorDark: "#333333", //二维码颜色
          colorLight: "#ffffff", //二维码背景色
          correctLevel: QRCode.CorrectLevel.L, //容错率，L/M/H        })
        });
      });
    },
    EWMSHIBIE() {
      this.erweimaObj = {};
      this.innerVisibleEWM = false;
      window.clearInterval(this.Timer);
    },
    // async chongxinGetInfo() {
    //   if (this.oneStatusMsg == 5) {
    //     const res = await goodsListApi.deleteerweimaTS(this.oneStatusObj.result.taskId, this.ONEsaleObj.id)
    //     if (res.code == 200) {
    //       this.ONEsaleSubmit()
    //     }
    //   }
    // },
    //新增
    addfnThreeId() {
      this.innerVisible = true;
    },
    selectthreeInfo(e) {
      console.log("e", e);
      let obj = this.threeListAllInfo.filter((item) => item.id == e);
      this.threeObjAll.saleCode = obj[0].saleName;
    },
    closefnthreeinfo() {
      this.innerVisible = false;
      this.threeObjAll = {
        accountId: null,
        config: null,
        saleCode: null,
        type: "add",
        outid: null,
      };
      this.dianjithreeId(this.threeObj);
    },
    async confirmthreeInfo() {
      this.threeObjAll.accountId = this.threeObj.id;
      const res = await gameListApi.addfnthreeId(this.threeObjAll);
      console.log(res);
      this.closefnthreeinfo();
      this.$message.success("操作成功！");
    },
    //编辑三方id
    editoutId(item) {
      console.log("item", item);
      this.$prompt("请输入三方ID", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputPattern: /^.+$/,
        inputErrorMessage: "内容不能为空！",
      })
        .then(async ({ value }) => {
          let obj = {};
          obj.accountId = this.threeObj.id;
          obj.config = item.config;
          obj.id = item.id;
          obj.outid = value;
          const res = await gameListApi.editthreeId(obj);
          console.log(res);
          this.dianjithreeId(this.threeObj);
          this.$message({
            type: "success",
            message: "操作成功！",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },
    async dianjithreeId(item) {
      this.threeObj = item;
      const res = await gameListApi.getthreeList(this.threeObj.id);
      console.log(res);
      if (res.code == 200) {
        this.threeListAll = res.rows;
        this.dioVisiblethree = true;
        gameListApi.getthreeId().then((dict) => {
          console.log("dict", dict);
          this.threeListAllInfo = dict.rows;
        });
      }
    },
    //转已空闲
    yikongxian(item) {
      this.$confirm(
        "此操作将该账号绑定的手机号状态改为已空闲状态, 是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(async () => {
          let obj = {
            id: item.telid,
            wyStatus: 2,
            wyGoodsId: item.id,
          };
          const res = await phoneApi.editListPhone(obj);
          console.log(res);
          this.getList();
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消操作",
          });
        });
    },
    resetUnbind(row) {
      this.$confirm("是否重置该账号掉绑状态?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.loading = true;
          goodsListApi.resetUnbind(row.id).then((res) => {
            this.loading = false;
            if (res.code == 200) {
              this.$message({
                type: "success",
                message: "重置成功!",
              });
              this.getList();
            } else {
              this.$message({
                type: "error",
                message: res.msg,
              });
            }
          });
        })
        .catch(() => {});
    },
    toTop(row) {
      this.$confirm("是否置顶该账号?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.loading = true;
          goodsListApi.toTop(row.id).then((res) => {
            this.loading = false;
            if (res.code == 200) {
              this.$message({
                type: "success",
                message: "置顶成功!",
              });
              this.getList();
            } else {
              this.$message({
                type: "error",
                message: res.msg,
              });
            }
          });
        })
        .catch(() => {});
    },
    // 点击价格  显示价格修改框
    priceClick(index, row) {
      if (
        this.actived != 0 &&
        row.saleState == 1 &&
        (this.pageType == "myAccount" || this.pageType == "admin")
      ) {
        this.showInputIndex = index;
        let str = `priceInput${row.id}`;
        this.$nextTick(() => {
          // this.$refs[str]
          console.log(
            "%c Line:481 🥐 this.$refs[str]",
            "color:#7f2b82",
            this.$refs
          );
          this.$refs[str][3].focus();
          this.$refs[str][3].select();
        });
      } else {
        return;
      }
    },
    // 提交价格修改
    priceEdit(row) {
      let obj = {
        price: row.newPrice,
        id: row.id,
      };
      goodsListApi.editPrice(obj).then((res) => {
        if (res.code == 200) {
          this.showInputIndex = "";
          this.$message.success("修改成功！");
        } else {
        }
      });
    },
    // 克隆账号
    clone(row) {
      this.$confirm("此操作将删除商品后重新上架该商品, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.loading = true;
          goodsListApi.goodsClone(row.id).then((res) => {
            this.loading = false;
            if (res.code == 200) {
              this.$message({
                type: "success",
                message: "克隆成功!",
              });
              this.getList();
            } else {
              this.$message({
                type: "error",
                message: res.msg,
              });
            }
          });
        })
        .catch(() => {});
    },
    openUrl(url) {
      window.open(url);
    },
    // 供货手机号
    getSupPhone(row) {
      this.supPhoneNum = "";
      getSupPhoneNumber({ userId: row.createId }).then((res) => {
        this.supPhoneNum = res.msg;
      });
    },
    // 更多价格
    getMore(row) {
      console.log("%c Line:1303 🍐 row", "color:#33a5ff", row);
      getMorePrice({ infoid: row.id }).then((res) => {
        console.log("%c Line:1304 🥚 res", "color:#7f2b82", res);
        this.morePrice = res.data;
      });
    },
    // 获取分销站域名
    getDomain() {
      getDicts("retailDomain").then((res) => {
        if (res.code == 200) {
          this.retailDomainList = res.data;
        }
      });
    },

    // 游戏列表
    getGameList() {
      gameListApi.getGameList().then((res) => {
        this.gameList = res.rows;
      });
    },
    // 导出列表
    handleExport() {
      this.exportLoading = true;
      let obj = JSON.parse(JSON.stringify(this.queryParams));
      obj.pageNum = "";
      obj.pageSize = "";
      goodsListApi.exportGoodsList(obj).then((res) => {
        if (res.code == 200) {
          this.$download.name(res.msg);
          this.exportLoading = false;
        }
      });
    },
    handleExportss() {
      this.exportLoading = true;
      let obj = JSON.parse(JSON.stringify(this.queryParams));
      obj.pageNum = "";
      obj.pageSize = "";
      goodsListApi.exportGoodsListss(obj).then((res) => {
        if (res.code == 200) {
          this.$download.name(res.msg);
          this.exportLoading = false;
        }
      });
    },
    handleExportssJYM() {
      this.exportLoading = true;
      let obj = {};
      obj.gameId = this.queryParams.gameId;
      goodsListApi.daochuJYM(obj).then((res) => {
        if (res.code == 200) {
          this.$download.name(res.msg);
          this.exportLoading = false;
        }
      });
    },
    selectSaleTime() {
      debugger;
      if (this.saleTimeArr.length > 1) {
        var startDate = moment(this.saleTimeArr[0]).format("YYYY-MM-DD");
        this.queryParams.saletimeStart = startDate + " 00:00:00";
        var endDate = moment(this.saleTimeArr[1]).format("YYYY-MM-DD");
        this.queryParams.saletimeEnd = endDate + " 23:59:59";
      }
    },
    // 获取列表
    getList() {
      this.tableData.records = [];
      this.loading = true;
      this.showInputIndex = "";
      if (this.pageType == "pool") {
        // getGoodsListPool 账号池
        goodsListApi
          .getGoodsListPool(this.queryParams)
          .then((response) => {
            this.$nextTick(() => {
              this.loading = false;
              this.tableData.records = JSON.parse(
                JSON.stringify(response.rows)
              );
              this.tableData.total = response.total;
            });
          })
          .catch((err) => {
            this.loading = false;
          });
      } else if (this.pageType == "myAccount") {
        // 我的账号
        goodsListApi
          .myAccount(this.queryParams)
          .then((response) => {
            this.$nextTick(() => {
              this.loading = false;
              this.tableData.records = JSON.parse(
                JSON.stringify(response.rows)
              );
              this.tableData.total = response.total;
            });
          })
          .catch((err) => {
            this.loading = false;
          });
      } else if (this.pageType == "salePort") {
        goodsListApi
          .getGoodsAllList(this.queryParams)
          .then((response) => {
            this.$nextTick(() => {
              this.loading = false;
              response.rows.forEach((item) => {
                this.gameList.forEach((demo) => {
                  if (item.gameName == demo.name) {
                    item.gameXINType = demo.gameType;
                  }
                });
              });
              this.tableData.records = JSON.parse(
                JSON.stringify(response.rows)
              );
              this.tableData.total = response.total;
            });
          })
          .catch((err) => {
            this.loading = false;
          });
      } else {
        goodsListApi
          .getGoodsAllList(this.queryParams)
          .then((response) => {
            this.$nextTick(() => {
              this.loading = false;
              this.tableData.records = JSON.parse(
                JSON.stringify(response.rows)
              );
              this.tableData.total = response.total;
            });
          })
          .catch((err) => {
            this.loading = false;
          });
      }
    },
    //获取供货商接口
    getUserList() {
      getSupplyList("supplyCustomer").then((res) => {
        if (res.code == 200) {
          this.supplyList = res.data;
        }
      });
    },
    // 获取推送接口列表
    getPushList() {
      getPushList({ status: 1 }).then((res) => {
        this.pushApiList = res.rows;
      });
    },
    // 打开更多搜索弹窗
    openMoreSearch() {
      if (!this.queryParams.gameId) {
        return this.$alert("请先选择游戏名称！");
      }
      this.$refs.moreSearch.open(this.queryParams.gameId);
    },
    // 更多搜索确认
    sureSearch(form) {
      this.queryParams = { ...this.queryParams, ...form };
      this.search();
    },
    // 搜索
    search() {
      this.queryParams.pageNum = 1;
      this.queryParams.pageSize = 20;
      this.getList();
    },
    // 隐藏无关属性
    onOfOff() {
      const list = JSON.parse(JSON.stringify(this.tableData.records));
      this.tableData.records = [];
      this.loading = true;
      setTimeout(() => {
        this.$nextTick(() => {
          this.tableData.records = JSON.parse(JSON.stringify(list));
          this.loading = false;
        });
      }, 300);
    },
    // 表格排序
    sortFun(val) {
      this.queryParams.sort = val.order;
      this.queryParams.sortColumn = val.prop;
      this.getList();
    },
    // tabs切换时触发
    tabChange() {
      console.log("333", this.actived);
      this.queryParams.saleState = this.actived;
      if (this.actived == 7) {
        this.queryParams.saleState = "";
        this.queryParams.del = 1;
      } else if (this.actived == 0 && this.pageType == "myAccount") {
        this.queryParams.saleState = "";
      } else {
        this.queryParams.del = "";
      }

      this.getList();
    },
    // 新增
    addACount() {
      this.$refs.addDialog.open("add");
    },
    showLogs(id) {
      this.$refs.showLogs.open(id);
    },
    // 批量发布
    addACountMore() {
      // importDialog
      this.$refs.importDialog.open();
      // this.$router.push({
      //   name:'Import'
      // })
    },
    // 转自售
    openOnSelf(row) {
      this.$refs.onSelfDialog.open(row);
    },
    // 表格选择项改变
    handleSelection(arr) {
      console.log("%c Line:442 🍆 表格选择改变", "color:#f5ce50", arr);
      this.selects = arr;
      this.ids = [];
      if (arr.length == 0) {
        this.ids = [];
      } else {
        arr.forEach((t) => {
          this.ids.push(t.id);
        });
      }
    },
    // 审核账号
    checkAccountFn(row) {
      let ids = [];
      if (row) {
        ids = row.id;
      } else {
        if (this.ids && this.ids.length > 0) {
          ids = this.ids.join(",");
        } else {
          this.$alert("请先选择账号！");
          return;
        }
      }
      if (ids) {
        this.$modal
          .confirm("确认审核通过吗？")
          .then(() => {
            goodsListApi.auditGoods(ids).then((res) => {
              this.$message.success(res.msg);
              this.getList();
            });
          })
          .catch(() => {});
      }
    },
    // 打开全部删除弹窗
    deleteAll() {
      this.$refs.deleteDialog.open();
    },
    // 批量下架
    piliangXiajia() {
      const ids = this.ids.join(",");
      if (!ids) {
        return this.$alert("请先选择数据！");
      }
      let that = this;
      this.$modal
        .confirm('是否确认下架编号为"' + ids + '"的数据项？')
        .then(function () {
          that.loading = true;
          goodsListApi
            .batchDown(ids)
            .then((res) => {
              that.loading = false;
              that.getList();
              that.$modal.msgSuccess(res.msg);
            })
            .catch((err) => {
              that.$modal.msgSuccess(err.msg);
            });
        })
        .catch(() => {});
    },
    // 批量复制
    copyBatch() {
      if (this.selects.length) {
        let str = "";

        this.selects.forEach((item) => {
          let hostt = `${this.retailDomainList[0].dictValue}/#/pages/detail/index?id=${item.id}`;
          str = `${str}商品编号：${item.id}\n自编号：${item.thirdId}\n区服：${
            item.systemName ? item.systemName + "/" : ""
          }${item.carrierName ? item.carrierName + "/" : ""}${item.groupName}${
            item.serverName
          }\n简介：${item.des}\n图片：${hostt}\n ===================== \n`;
        });
        this.$copyText(str).then(
          (e) => {
            this.$message({
              type: "success",
              message: "已复制到剪切板！",
            });
          },
          function (e) {}
        );
      } else {
        return this.$alert("请先选择数据！");
      }
    },
    // 删除
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row ? row.id : this.ids.join(",");
      if (!ids) {
        return this.$alert("请先选择数据！");
      }
      let that = this;
      this.$modal
        .confirm('是否确认删除游戏账号编号为"' + ids + '"的数据项？')
        .then(function () {
          that.loading = true;
          goodsListApi
            .delGoods(ids)
            .then((res) => {
              that.loading = false;
              that.getList();
              that.$modal.msgSuccess(res.msg);
            })
            .catch((err) => {
              that.$modal.msgSuccess(err.msg);
            });
        })
        .catch(() => {});
    },
    // 批量推送
    // 推送
    pushBatch(item) {
      if (this.ids.length > 1) {
        this.$modal.msgError("只能选择一条数据");
        return true;
      } else if (this.ids.length == 0) {
        this.$modal.msgError("请先选择一条数据");
        return true;
      }
      this.$refs.pushDialog.open({
        id: this.ids[0],
        configId: item,
      });
    },
    // 下单
    commitOrder(item) {
      this.$refs.orderCommit.open(item);
    },
    // 销售端客服提号
    addOrder(item) {
      this.$refs.tihaoDialog.open(item);

      // console.log("%c Line:763 🧀 row", "color:#33a5ff", item);
      // let now = formatDate(new Date())
      // // 组装复制数据 商品编号、游戏名称、区服、账号、密码、提号日期（当前时间）
      // let copyTxt = `商品编号：${item.id}\n游戏名称：${item.gameName}\n区服：${item.systemName ? item.systemName + '/' : ''}${item.carrierName ? item.carrierName + '/' : ''}${item.groupName}${item.serverName}\n账号：${item.accountNumber}\n密码：${item.accountPassword}\n提号日期：${now}`;
      // this.$copyText(copyTxt).then(
      //   (e)=> {
      //     this.$message.success("商品信息已复制到剪切板")
      //   })
      // this.$modal
      //   .confirm(
      //     "商品信息已复制到剪切板，是否确认提取编号为" + item.id + '"的游戏账号？'
      //   )
      //   .then(() => {
      //     goodsListApi.salePickUp(item.id).then(res => {
      //       this.$modal.msgSuccess(res.msg);
      //       this.getList()
      //     })
      //   })
    },
    // 下架商品
    downSale(id) {
      this.$prompt("下架原因", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputPattern: /\S/,
        inputErrorMessage: "请填写下架原因",
      })
        .then(({ value }) => {
          this.$modal
            .confirm("是否确认下架编号为" + id + '"的游戏账号？')
            .then(() => {
              goodsListApi
                .downGoods({
                  downDes: value,
                  id: id,
                })
                .then((res) => {
                  this.$modal.msgSuccess(res.msg);
                  this.getList();
                });
            });
        })
        .catch(() => {});
    },
    // 上架商品
    upSale(id) {
      // this.$modal
      //   .confirm(
      //     "是否确认上架编号为" + id + '"的游戏账号？'
      //   )
      //   .then(() => {
      //     goodsListApi.upGoods(id).then(res => {
      //       this.$modal.msgSuccess(res.msg);
      //       this.getList()
      //     })
      //   })
      this.$prompt("请输入上架原因", "温馨提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputPattern: /.+/,
        inputErrorMessage: "请输入上架原因",
      })
        .then(({ value }) => {
          let obj = {};
          obj.problemDes = value;
          obj.id = id;
          goodsListApi.upGoodShop(obj).then((res) => {
            this.$modal.msgSuccess(res.msg);
            this.getList();
          });
          this.$message({
            type: "success",
            message: "操作成功！",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },

    // 转为问题号
    transQues(row) {
      this.$refs.zhuanWenTiDialog.open("zwt", row);
      // this.$prompt('问题描述', '提示', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   inputPattern: /\S/,
      //   inputErrorMessage: '请填写问题描述'
      // }).then(({ value }) => {
      //   this.$modal
      //     .confirm(
      //       "是否确认编号为" + id + '"的游戏账号转为问题账号？'
      //     )
      //     .then(() => {
      //       goodsListApi.problemGoods({
      //         problemDes: value,
      //         id: id
      //       }).then(res => {
      //         this.$modal.msgSuccess(res.msg);
      //         this.getList()
      //       })
      //     })
      // }).catch(() => {

      // });
    },
    // 编辑提号备注
    editTihaoBeizhu(row) {
      let obj = {
        id: row.id,
        remake: row.salenote,
      };
      this.$refs.editTihao.open("edit", obj);
    },
    // 编辑问题账号问题备注
    editProblemDes(row) {
      let obj = {
        id: row.id,
        problemDes: row.problemDes,
        problemTypeName: row.problemTypeName,
      };
      this.$refs.zhuanWenTiDialog.open("edit", obj);
    },
    // 转为找回
    transZhaohui(row) {
      this.$refs.zhaohuiDialog.open("zzh", row);
    },
    // 转为已售
    transYishou(row) {
      goodsListApi.toSaled(row.id).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("操作成功");
          this.getList();
        }
      });
    },
    // 找回列表查看找回原因
    transZhaohuiEdit(row) {
      let obj = {
        id: row.id,
        retrieveDes: row.retrieveDes, //找回原因
        retrieveHandleImages: row.retrieveHandleImages, //图片
        retrieveHandleType: row.retrieveHandleType, //找回情况
      };
      this.$refs.zhaohuiDialog.open("edit", obj);
    },
    // 改变状态
    handleAudit(type, operation, id, flag) {
      const ids = id;
      let params = {};
      params.type = type;
      params.operation = operation;

      // 转为问题号需要备注
      if (type == 4 && !flag) {
        this.showDialogTitle = "转为问题号";
        this.tempData = params;
        this.tempData.ids = ids;
        this.dialogFormVisible = true;
        return;
      }
      // 下架需要填写原因
      if (type == 7 && !flag) {
        this.showDialogTitle = "下架原因";
        this.tempData = params;
        this.tempData.ids = ids;
        this.dialogFormVisible = true;
        return;
      }
      if (type == 4) {
        params.note = this.unsoldFrom.note;
      }
      if (type == 7) {
        params.offres = this.unsoldFrom.note;
      }
      this.$modal
        .confirm(
          "是否确认" + operation + '游戏账号编号为"' + ids + '"的数据项？'
        )
        .then(function () {
          return auditInfo(ids, params);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess(operation + "成功");
        })
        .catch(() => {});
    },
    // // 上架
    // upAccountCommit(id) {
    //   this.$modal
    //     .confirm("是否确认上架" + id + '"？')
    //     .then(function () {
    //       return upAccount(id);
    //     })
    //     .then(() => {
    //       this.getList();
    //       this.$modal.msgSuccess("上架成功");
    //     })
    //     .catch(() => { });
    // },
    // 转为问题号，下架
    confirmSub(flag) {
      this.dialogFormVisible = false;
      this.handleAudit(
        this.tempData.type,
        this.tempData.operation,
        this.tempData.ids,
        true
      );
    },
    // 双击编辑信息
    handleUpdate(row) {
      if (
        (this.actived != 1 && this.actived != 0 && this.actived != 10) ||
        this.pageType == "pool" ||
        this.pageType == "salePort"
      ) {
        this.$refs.addDialog.open("view", row, this.pageType);
      } else if (
        row.saleState != 1 &&
        row.saleState != 0 &&
        this.actived != 10
      ) {
        this.$refs.addDialog.open("view", row, this.pageType);
      } else {
        this.$refs.addDialog.open("edit", row, this.pageType);
      }
    },
    // 查看备注
    showSinNum(row) {
      this.sinNumShow = row.sinNum;
      this.showSinNumVisible = true;
    },
    // 选择游戏
    selectGameType(val) {
      if (!val) {
        val = null;
        this.sysList = [];
        this.carrierList = [];
        this.areaList = [];
        return;
      }
      this.gameList.forEach((r) => {
        if (r.id == val) {
          this.GameSelectedType = r.type;
        }
      });
      if (this.GameSelectedType === 0) {
        // 手游
        // 获取系统列表和运营商列表
        this.getSysList();
        this.getYysList();
      } else {
        // 端游
        // 获取大区列表
        this.getAreaList2();
      }
      this.search();
    },
    // 获取系统列表
    getSysList() {
      gameDictionaryApi
        .getChildList({
          gameId: this.queryParams.gameId,
          systemKey: "system",
        })
        .then((res) => {
          this.sysList = res.rows;
        });
    },
    // 获取运营商列表
    getYysList() {
      gameDictionaryApi
        .getChildList({
          gameId: this.queryParams.gameId,
          systemKey: "carrier",
        })
        .then((res) => {
          this.carrierList = res.rows;
        });
    },
    // 运营商改变  获取大区列表
    getAreaList(e) {
      this.search();
      let obj = {
        gameId: this.queryParams.gameId,
        systemKey: "group",
      };
      this.queryParams.groupId = "";
      this.queryParams.serverId = "";

      // 运营商改变 找出选择的运营商的对象
      if (e) {
        this.carrierList.forEach((i) => {
          if (i.id == e) {
            obj.systemKey = i.systemKey + "group";
          }
        });
      }
      gameDictionaryApi.getChildList(obj).then((res) => {
        this.areaList = res.rows;
      });
    },
    // 大区改变  获取服务器列表
    getServiceList(e) {
      this.search();
      this.queryParams.serverId = "";

      if (e) {
        gameDictionaryApi
          .getList({
            parentId: e,
          })
          .then((res) => {
            this.serverList = res.rows;
          });
      } else {
        this.serverList = [];
      }
    },
    //端游 直接获取大区
    getAreaList2() {
      let obj = {
        gameId: this.queryParams.gameId,
        systemKey: "group",
      };
      gameDictionaryApi.getChildList(obj).then((res) => {
        this.areaList = res.rows;
      });
    },
    // 加入验证手机号
    addCheck(row) {
      checkPhoneApi
        .add({
          accountId: row.id,
          account: row.accountNumber,
          checkTel: row.securityPhone,
        })
        .then((res) => {
          this.$message.success(res.msg);
          this.getList();
        });
    },
    // 交易中复制商品信息
    keyCopy2(item) {
      // 查询注意事项
      let str = "";
      let arr = this.gameList.filter((r) => {
        return r.id == item.gameId;
      });
      if (arr && arr.length) {
        str = arr[0].notice;
      }
      // 组装复制数据 商品编号、游戏名称、区服、账号密码、换绑信息--注意事项
      let copyTxt;
      if (item.gameName == "原神" || item.gameName == "崩坏星穹铁道") {
        copyTxt = `商品编号：${item.id}\n游戏名称：${item.gameName}\n区服：${
          item.systemName ? item.systemName + "/" : ""
        }${item.carrierName ? item.carrierName + "/" : ""}${item.groupName}${
          item.serverName
        }\n账号：${item.accountNumber}\n密码：${
          item.accountPassword
        }\n换绑信息：${item.changeBindInfo}\n注意事项：${str}`;
      } else {
        copyTxt = `商品编号：${item.id}\n游戏名称：${item.gameName}\n区服：${
          item.systemName ? item.systemName + "/" : ""
        }${item.carrierName ? item.carrierName + "/" : ""}${item.groupName}${
          item.serverName
        }\n账号：${item.accountNumber}\n密码：${
          item.accountPassword
        }\n注意事项：${str}`;
      }

      this.$copyText(copyTxt).then((e) => {
        this.$message.success("商品信息已复制到剪切板");
      });
    },
    // 复制商品信息
    keyCopy(item) {
      let hostt = `${this.retailDomainList[0].dictValue}/#/pages/detail/index?id=${item.id}`;
      this.copyVlaue = `商品编号：${item.id}\n\n区服：${
        item.systemName ? item.systemName + "/" : ""
      }${item.carrierName ? item.carrierName + "/" : ""}${item.groupName}${
        item.serverName
      }\n简介：${item.des}\n图片：${hostt}`;
    },
    // 复制成功和失败的方法
    onCopy(e) {
      this.$modal.msgSuccess("复制成功");
      this.copyVlaue = "";
    },
    onError() {
      this.$modal.msgError("复制失败");
      this.copyVlaue = "";
    },
    //重置
    resetQuery() {
      let dataType = this.queryParams.dataType;
      this.queryParams = {
        pageNum: 1,
        pageSize: 20,
        saleState: "",
        // operType: "supply",
        //        sort: "descending",
        //        sortColumn: "createTime",
        dataType: dataType,
      };
      this.queryParams.saleState = this.actived ? this.actived : "";
      this.getList();
    },
    // getHost() {
    //   getDicts("apphost").then(res => {
    //     if (res.code == 200) {
    //       console.log(res);
    //       if (res.data.length > 0) {
    //         this.hoste = res.data[0].dictValue;
    //       }
    //     }
    //   });
    // },
    // 每页条数改变
    handleSizeChange(val) {
      this.queryParams.pageSize = val;
      this.getList();
    },
    // 页码改变
    handleCurrentChange(val) {
      this.queryParams.pageNum = val;
      this.getList();
    },
  },
};
</script>
<style lang="scss" scoped>
.zdy-des {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  margin: 6px 0;
}

#qrCode {
  display: inline-block;
  margin: 0 auto;
  /*水平居中*/
  position: relative;
  top: 15%;

  /* img: {
    width: 200px;
    height: 200px;
    background-color: #fff; //设置白色背景色
    padding: 6px; // 利用padding的特性，挤出白边
  } */
}

.search-form-new ::v-deep .el-input {
  width: 200px !important;
}

.sign {
  display: inline-block;
  width: 20px;
  height: 20px;
  background-color: #ffcc66;
  border-radius: 50%;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  color: #fff;
  margin-right: 5px;

  &.ping {
    background-color: #1890ff;
  }
}

#qqq {
  background-color: #111;
  width: 300px;
  height: 300px;
  margin: 0 auto; /*水平居中*/
  position: relative;
}
#qrCode {
  display: inline-block;
  margin: 0 auto; /*水平居中*/
  position: relative;
  top: 15%;
}
</style>
